#include <iostream>
using namespace std;

class Parent {
	public:
		Parent() {};
		virtual~Parent() {
			cout << "Destructor Parent" << endl;
		}
		virtual void fn() {
			cout << "Call Parent fn" << endl;
		}
};

class Child : public Parent {
	public:
		~Child() {
			cout << "Destructor Child" << endl;
		}
		virtual void fn () {
			cout << "Call Child fn" << endl;
		}
};

void test (Parent &obj) {
	obj.fn();
}

void fun (void) {
	Parent obj1;
	Child obj2;
	Parent *obj3 = new Child;
	test(obj1);
	test(obj2);
	test(*obj3);
	delete obj3;
	return;
}

int main(void) {
	fun();
	return 0;
}
